import { Provide} from '@midwayjs/core';
import { Store } from '../entity/admin/store';
import { InjectEntityModel } from '@midwayjs/orm';
import { Repository } from 'typeorm';


@Provide()
export class AdminService {

  @InjectEntityModel(Store)
  storeModel:Repository<Store>
  
  async login(storenum: number,password: string):Promise<Store>{
    try{
     const result = await this.storeModel.findOneBy({storenum});
     if(result){
      // let checkPassword = await getMd5Password(inputPassword,result.salt)
      // console.log("加密后的输进来的密码:   "+checkPassword)
      // console.log("数据库里的密码:   "+result.password);
      console.log(result);     
      if(result.password == password){
          return result
      }else{
          return null
      }
  }else{
      return null
  }
    }catch(error){
      console.log(error);
    }
  }
}
